home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
vedt.zip
/
WILDFILE.VDM
< prev
next >
Wrap
Text File
|
1990-08-15
|
5KB
|
182 lines
! Macro WILDFILE.VDM
!
! Updated March 6, 1990
!
! This macro runs any VEDIT command or another macro on an entire group of
! files. The files may either be specified individually or with wildcards.
!
! INTERNALLY:
! This macro generates in register 2 a sequence of open file, display
! filename, execute macro M(3), and close file instructions.
!
! Register Usage:
!
! 2 Contains sequence of "EB","M(3)","EY" instructions
! 3 Hold command or macro executed for each file
! 8 Hold search string
! 9 Hold filenames entered by user; replace string
!
! Q80 User keyboard response to questions (temp)
! Q81 Flag whether macro stops after each filename
! Q84 Hold original ES 4 value
! Q86 ES 6 value
! Q88 ES 8 value
! Q89 ES 8 value
!
!****************************************************************************
!
!
EE(@) R* Check main buffer
(.oa==0 | .of==0)[ EZY ][ R* If unaltered or no file open clear it
YA YEN R* Else confirm saving it...
@YT"Do you want to save the file in the main edit buffer?" YEN
@YT"[S]ave file; [A]bandon file; [C]ancel macro : "
[ @XK(100)"" Q100&95XS(100) (Q100=="S | Q100=="A | Q100=="C)JL YA ] Q100:YD
YEN
(Q100=="C)[ JO ]
(Q100=="S)[ EY ][ EZY ] R* Save or abandon the file
]
ES 4 1 .rvXS(84) !Save original ES values; set new ones
ES 6 0 .rvXS(86)
ES 8 1 .rvXS(88)
ES 9 1 .rvXS(89)
EE(2) EZY !Switch to and empty edit buffer 2
YEC
YT/
*****************************************
* *
* VEDIT *
* Multi-file Macro Driver *
* *
*****************************************
Enter the names of the files you want to operate on and <Enter>.
(The wildcards '?' and '*' may be used).
Press <Enter> twice when done.
/
!
! Query and get user response in Register #9.
! Expand wildcards into filenames. Place filenames with complete
! pathname in edit buffer 2.
!
#[
!FLOOP!
:RQ(9)"Enter Filename: " (.u9=0)_JL
:ED|R9 !Test if file(s) exist (.rv==0 if not)
(.rv=0) [YT"File(s) not found. Try again." YEN JP"FLOOP" ]
Z .pXS(0) !Goto end of buffer and save position
YI 1ED|R9 -YI !Insert directory into edit buffer 2
Q0EJ !Restore position
F"Directory " !Search for "Directory" header
-K !Delete partial header and previous blank line
.pXS(0) !Save current position
$F"|>" !Advance to end of line
Q0,.pRC(3) !Copy drive:pathname to register 3
0KK !Delete rest of header
!
! Cleanup filenames.
!
B #[$F"|<|>" ; 0KK ] !Remove blank lines
B #[F"*" ; 0KK ] !Remove sub-directory entries containing "*"
B #[F".EXE" ; 0KK ] !Don't attempt to edit ".COM" or ".EXE" files
B #[F".COM" ; 0KK ]
B #$S"|W"" !Eliminate excess white space (in filenames)
Q0EJ !Restore position
#[
$F"|<|X" ; -C RG(3) !Precede each filename with full drive:pathname
(.os=4)[I"/"][I"\" ] !Unix needs "/"; DOS needs "\"
]
]
!
! Prompt for "C", "M" or "S"; convert to upper case; check for valid reply
!
#[ YEN XK(80)\Execute a [C]ommand, [M]acro, [S]earch or [R]eplace? (C/M/S/R): \
Q80&223 XS(80) ((Q80="C) ^ (Q80="M) ^ (Q80="S) ^ (Q80="R))_JL YA
]
(Q80="C)[ 2YEN :RQ(3)"Enter Command: "
][
(Q80="M)[
2YEN :RQ(9)"Enter filename of macro: "
+RL(3) |R9
][
2YEN :RQ(8)"Enter search string (and Enter): "
!
! Build macro in current edit buffer, 91EI and 93EI create brackets
! Use 255(decimal) as explicit delimiters
!
(Q80="S)[
EE(@) EZY 91EI I"@_F" 255EI RG(8) 255EI
][
YEN :RQ(9)"Enter replace string (and Enter): "
EE(@) EZY 91EI I"@_S" 255EI RG(8) 255EI RG(9) 255EI
]
#[ YEN XK(80)\[D]isplay line or enter [V]isual Mode? (D/V): \
Q80&223 XS(80) ((Q80="D) ^ (Q80="V))_JL YA
]
(Q80="D)[
I" @YT\LINE:\ .lnXS(80) :XT(80) @YT\ \ 0TT" 93EI
][
I"V" 93EI
]
-#RC(3) EZY EE(2) !Copy to register #3 and clear edit buffer
]
]
!
! Does user want macro to pause after each filename?
! If Visual mode above, no need to pause
!
(Q80="V)[ "NXS(81)
][
#[ YEN XK(81)\Should macro pause after each file is processed? (Y/N): \
Q81&223 XS(81) ((Q81="Y) ^ (Q81="N))_JL YA
]
]
!
! Insert EB ...$ EW$ M(3) EY
!
B
#[
.eof_JL
I"EB "
$F"|>"
(Q81="Y)[ I" YEN @YT\...Processing \ :EW 2YEN M(3) +@XK(80)\Press any key to continue...\ :EY"
][
I" YEN @YT\...Processing \ :EW 2YEN M(3) :EY"
]
:L
]
!
! Make main buffer active and pre-clear it
!
EE(@)
EZY
XK(81)"
Press any key to begin operation..."
.wt>1[YWI] !Delete any windows
ES 4 Q84 !Restore most original ES values
ES 6 Q86
ES 9 Q89
(Q80="V)[
YWB(H) 1 YWS(H)
@YT" Press [VISUAL EXIT] (<CTRL-E>) to search for next occurrence."
YWS(@)
]
M(2)
ES 8 Q88 !Restore original ES value
(.mn<>"Z)[JM !If macro not in register "Z", it is now done
][ EXA ] !Else we exit VEDIT